//package com.yunhe.device.controller.device;
//
//import com.yunhe.common.model.PageParam;
//import com.yunhe.device.domain.device.ConnectivityNode;
//import com.yunhe.common.exception.ArgumentErrorException;
//import com.yunhe.common.exception.ObjectNotFoundException;
//import com.yunhe.common.exception.UniqueConstraintsException;
//import com.yunhe.common.model.DomainList;
//import com.yunhe.common.model.ResultObject;
//import com.yunhe.device.service.device.ConnectivityNodeService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.Optional;
//
///**
// * 连接节点Controller
// * @author liuronglei
// */
//@Api(value = "connectivityNode", description = "连接节点维护", tags = {"Model_ConnectivityNode"})
//@RestController
//@RequestMapping("/connectivityNodes")
//public class ConnectivityNodeController {
//    @Autowired
//    private ConnectivityNodeService connectivityNodeService;
//
//    /**
//     * 新增连接节点
//     * @param connectivityNode 连接节点对象
//     */
//    @ApiOperation("新增连接节点")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "svgCode", value = "SVG编号", dataType = "string", paramType = "query")
//    })
//    @RequestMapping(method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(
//            @RequestBody ConnectivityNode connectivityNode)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
//        ConnectivityNode newConnectivityNode = connectivityNodeService.createConnectivityNode(connectivityNode);
//        return new ResponseEntity<>(new ResultObject<>(newConnectivityNode), HttpStatus.OK);
//    }
//
//    /**
//     * 批量新增连接节点
//     * @param domainList 连接节点对象列表
//     */
//    @ApiOperation("批量新增连接节点")
//    @RequestMapping(value = "/batch", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(
//            @RequestBody DomainList<ConnectivityNode> domainList)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
//        Iterable<ConnectivityNode> newConnectivityNodes =
//                connectivityNodeService.createConnectivityNode(domainList.getList());
//        return new ResponseEntity<>(new ResultObject<>(newConnectivityNodes), HttpStatus.OK);
//    }
//
//    /**
//     * 根据ID删除连接节点
//     * @param id id
//     */
//    @ApiOperation("根据ID删除连接节点")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "连接节点ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> delete(
//            @PathVariable("id") Long id) {
//        connectivityNodeService.deleteConnectivityNode(id);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 根据代码删除连接节点
//     * @param code 代码
//     */
//    @ApiOperation("根据代码删除连接节点")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "代码", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/byCode/{code}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> deleteByCode(
//            @PathVariable("code") Long code) {
//        Long result = connectivityNodeService.deleteConnectivityNodeByCode(code);
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }
//
//    /**
//     * 更新连接节点（更新全部字段）
//     * @param id ID
//     * @param connectivityNode 连接节点对象
//     */
//    @ApiOperation("更新连接节点（更新全部字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> put(
//            @PathVariable("id") Long id,
//            @RequestBody ConnectivityNode connectivityNode)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
//        connectivityNode.setId(id);
//        ConnectivityNode newConnectivityNode = connectivityNodeService.updateConnectivityNode(connectivityNode);
//        return new ResponseEntity<>(new ResultObject<>(newConnectivityNode), HttpStatus.OK);
//    }
//
//    /**
//     * 更新连接节点（更新指定字段）
//     * @param id ID
//     * @param code 代码
//     * @param name 编号
//     */
//    @ApiOperation("更新连接节点（更新指定字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long", paramType = "path"),
//            @ApiImplicitParam(name = "code", value = "代码", dataType = "Long", paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "编号", dataType = "string", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
//    public ResponseEntity<ResultObject> patch(
//            @PathVariable("id") Long id,
//            @RequestParam("code") Optional<Long> code,
//            @RequestParam("name") Optional<String> name)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        ConnectivityNode newConnectivityNode = connectivityNodeService.updateConnectivityNode(id, code.orElse(null), name.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(newConnectivityNode), HttpStatus.OK);
//    }
//
//    /**
//     * 根据设备ID获得连接节点对象
//     * @param id ID
//     */
//    @ApiOperation("根据ID获得连接节点对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "设备ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> get(
//            @PathVariable("id") Long id) {
//        ConnectivityNode connectivityNode = connectivityNodeService.findByConnectivityNodeId(id);
//        return new ResponseEntity<>(new ResultObject<>(connectivityNode), HttpStatus.OK);
//    }
//
//    /**
//     * 根据代码获得连接节点对象
//     * @param code 代码
//     */
//    @ApiOperation("根据代码获得连接节点对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "代码", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/byCode/{code}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByCode(
//            @PathVariable("code") Long code) {
//        ConnectivityNode connectivityNode = connectivityNodeService.findByCode(code);
//        return new ResponseEntity<>(new ResultObject<>(connectivityNode), HttpStatus.OK);
//    }
//
//    /**
//     * 根据条件获得连接节点列表
//     */
//    @ApiOperation("根据条件获得连接节点列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search(
//            @ModelAttribute PageParam pageParam) {
//        Iterable<ConnectivityNode> results = connectivityNodeService.findConnectivityNodes(pageParam);
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//
//    /**
//     * 连接节点绑定设备
//     * @param code 代码
//     * @param devCode 设备代码
//     * @param terminal 端子代码
//     */
//    @ApiOperation("连接节点绑定设备")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "代码", required = true, dataType = "Long", paramType = "path"),
//            @ApiImplicitParam(name = "devCode", value = "设备代码", required = true, dataType = "Long", paramType = "path"),
//            @ApiImplicitParam(name = "terminal", value = "端子代码", dataType = "String", paramType = "query")
//    })
//    @RequestMapping(value = "/byCode/{code}/devices/{devCode}", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> bindDev(
//            @PathVariable("code") Long code,
//            @PathVariable("devCode") Long devCode,
//            @RequestParam("terminal") Optional<String> terminal)
//            throws ArgumentErrorException, UniqueConstraintsException {
//        connectivityNodeService.bindDev(code, devCode, terminal.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 连接节点解绑设备
//     * @param code 代码
//     * @param devCode 设备代码
//     */
//    @ApiOperation("连接节点解绑设备")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "代码", required = true, dataType = "Long", paramType = "path"),
//            @ApiImplicitParam(name = "devCode", value = "设备代码", required = true, dataType = "Long", paramType = "path"),
//    })
//    @RequestMapping(value = "/byCode/{code}/devices/{devCode}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> unbindDev(
//            @PathVariable("code") Long code,
//            @PathVariable("devCode") Long devCode)
//            throws ArgumentErrorException, UniqueConstraintsException {
//        connectivityNodeService.unbindDev(code, devCode);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 根据代码获取连接节点绑定的设备
//     * @param code 代码
//     */
//    @ApiOperation("根据代码获取连接节点绑定的设备")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "代码", required = true, dataType = "Long", paramType = "path"),
//    })
//    @RequestMapping(value = "/byCode/{code}/devices", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search(
//            @PathVariable("code") Long code)
//            throws ArgumentErrorException, UniqueConstraintsException {
//        Iterable results = connectivityNodeService.search(code);
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//}